#-*- coding:utf-8 -*-
"""
浮动窗口
"""


import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *



class FloatingBaseWindow(QWidget):

    def __init__(self):
        super(FloatingBaseWindow, self).__init__()




class Warn(FloatingBaseWindow):

    def __init__(self,_title='',_content='',_width=500,_height=150,_title_font_size=14,_content_font_size=12):

        super(Warn, self).__init__()

        self.bit_font = QFont("",_title_font_size,65)
        self.lit_font = QFont('',_content_font_size,55)
        self.btn_style= """QPushButton{color:#8be133}
                                  QPushButton:hover{color:red}
                                  QPushButton{background-color:#A9A9A9}
                                  QPushButton{border:2px}
                                  QPushButton{border-radius:1px}
                                  QPushButton{padding:1px 1px}"""


        self.setWindowFlags(Qt.WindowStaysOnTopHint|Qt.FramelessWindowHint)
        self.setFixedWidth(500)
        self.setFixedHeight(150)
        self.main_laytout = QVBoxLayout()

        self.btn_layout = QHBoxLayout()
        self.btn_layout.setAlignment(Qt.AlignRight)
        self.close_btn = QPushButton("x")
        self.close_btn.clicked.connect(lambda x:self.close())
        self.close_btn.setFixedWidth(20)
        self.close_btn.setStyleSheet(self.btn_style)
        self.btn_layout.addWidget(self.close_btn)

        self.info_layout = QVBoxLayout()
        self.info_layout.setSpacing(20)
        self.main_label = QLabel(_title,self)
        self.main_label.setStyleSheet('QLabel{color:red}')
        self.main_label.setFont(self.bit_font)
        self.main_label.setAlignment(Qt.AlignHCenter)
        self.content_label = QLabel(_content,self)
        self.content_label.setFont(self.lit_font)
        self.content_label.setContentsMargins(0,130,0,0)
        self.content_label.setAlignment(Qt.AlignHCenter)
        self.info_layout.addWidget(self.main_label)
        self.info_layout.addWidget(self.content_label)



        self.main_laytout.addLayout(self.btn_layout)
        self.main_laytout.addLayout(self.info_layout)

        self.setLayout(self.main_laytout)

        self.initPos()


    def initPos(self):
        desktop = QApplication.desktop()
        d_width = desktop.width()
        d_height = desktop.height()
        width = self.width()
        height = self.height()

        finnal_width = d_width - width
        finnal_height = d_height - height
        self.move(finnal_width,finnal_height)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    t = Warn('存储空间不足!!!','空间不足1T')
    t.show()
    sys.exit(app.exec_())
